/*
游戏相关的主要配置文件;wxAppInfo主要包括app的登陆和分享信息;wxH5Info主要包括h5版本的登陆和分享信息(雀九未发布h5版本,暂未使用该数据);还包括版本校验的数据和一些场景相关的数据;
*/
var cfg = {
  //app相关信息
  wxAppInfo : {
    access_token_url : "https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code",
    refresh_token_url : "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=APPID&grant_type=refresh_token&refresh_token=REFRESH_TOKEN",
    APP_ID : "wxddd0a0f4fde3a675",
    SECRET : "711b0c749dd3907aff835b7d1fbc3372",
    WX_CODE : "",
    WX_ACCESS_TOKEN : "",
    WX_OPEN_ID : "",
    WX_UNIONID : "",
    WX_LOGIN_RETURN : "",
    WX_REFRESH_TOKEN : "",
    payURL : "http://qiadmin.njhuajia.com/index.php/Tips/showpay",
    shareURL : "http://qiadmin.njhuajia.com/index.php/download/nn", //"http://game.37yiyou.cn/download/nngame/download.html?from:groupmessage",
    newShareWord : "快加入房间跟我一起玩转旅游岛棋牌吧！",
    shareTitle : "海南首款雀九棋牌手游隆重登场，快来一起（戳我）下载娱乐吧！",
    shareDes : "海南首款雀九棋牌手游隆重登场，快来一起（戳我）下载娱乐吧！"
  },
  //H5相关信息
  wxH5Info : {
    joinLayerData : -1,
    showJoinLayer : false,
    h5Width : 720,
    h5Height : 1280,
    h5SceneID : 0,
    h5InviteCode : "0",
    h5RoomID : "0",
    h5SignID : "wxc0f7af4749ce7176",
    h5SignTime : "",
    h5SignTicket : "",
    h5SignSignature : "",
    h5SignStr : "niuniuH5",
    h5SignURL : "",
    h5LoginUrl : "http://nnapi.5d8d.com/111?state=0",
    h5ShareUrlNew : "http://nnapi.5d8d.com/111?state=0",
    h5ShareIco : "http://update.5d8d.com/111/MP_ICO.png"
  },

  userInfo : {
    diamond : -1,
    uid : -1,
    nickname :-1,
    head : -1,
    history : -1,
    sex : -1,
    playerId : -1
  },

  useNewMode : true,
  host : 0,
  port : 0,
  loginFirstTime : true,
  curUID : 0,
  meChair : 0,
  curPlayerCount : 0,
  curPlayerMax : 0,
  playerMax : 6,
  curPlayerData : {}, //转换之后的数据
  getCurChair : function(newChair){   //获取转换过后的椅子,客户端椅子号s
    if(cfg.isBalcony)
      return parseInt(newChair);
    else
      // return (parseInt(newChair) + cfg.playerMax - cfg.meChair) % cfg.playerMax;
      if( parseInt(cfg.meChair) == 0)
      {
        return (parseInt(newChair) + cfg.playerMax - cfg.meChair) % cfg.playerMax;
      }
      else
      {
        if(parseInt(newChair) < parseInt(cfg.meChair))
        {
          return parseInt(newChair) + 1;
        }
        else if (parseInt(newChair) > parseInt(cfg.meChair))
        {
          return parseInt(newChair);
        }
        else
        {
          return 0;
        }
      }
  },
  getOriChair : function(newChair){   //获取转换过前的椅子,服务端原始椅子号;
    if(cfg.isBalcony)
      return parseInt(newChair);
    else
      if( parseInt(cfg.meChair) == 0)
      {
        return (parseInt(newChair) + cfg.meChair) % cfg.playerMax;
      }
      else
      {
        if(parseInt(newChair) == 0)
        {
          return cfg.meChair
        }
        else if(parseInt(newChair) <= parseInt(cfg.meChair))
        {
          return parseInt(newChair) - 1;
        }
        else if (parseInt(newChair) > parseInt(cfg.meChair))
        {
          return parseInt(newChair);
        }
      }
  },
  addPlayerLateList : {},
  addPlayerLateCount : 0,

  addOnePlayerLate : function(playerData){
    cfg.addPlayerLateList[cfg.addPlayerLateCount] = playerData;
    cfg.addPlayerLateCount ++;
  },
  curDiamond : -1,
  curHistory : {},
  curSex : 1,   //1:M,0:F;

  roomPlayer : -1,
  roomId : -1,
  roomData : -1,
  cardFrameMap : {},
  bigCardFrameMap : {},
  niuTypeFrameMap : {},
  niuTypeFrameMapFK : {},
  sanKungTypeFrameMap : {},
  jinHuaTypeFrameMap : {},
  paiGowTypeFrameMap : {},
  paiGowCardFrameMap : {},
  paiGowTypeFrameMapB :{},

  faceFrameMap : {},
  faceAniMap : {},
  loadFaceAni : false,
  loadFaceFrame : false,

  cardBackFrame : -1,
  noticeData : -1,

  audioBgId : null,
  audioList : [],
  audioVolume : 1,
  musicEnable : true,
  soundEnable : true,
  gameSceneLoadOver : false,
  gameSceneLoadData : [],
  hallSceneLoadData : [],
  isBalcony : false,

  playerLimits : -1,
  curUseId : -1,
  curUseToken : -1,
  curUseCode : -1,
  firstShowNotice : true,

  GVoiceIsInit : false,
  GVoiceRoomID : -1,

  loadNode : {},
  curGameScene : {},

  ON_LOGIN : 1000,
  ON_HALL : 1001,
  ON_GAME : 1002,
  ON_OVER : 1005,
  
  curReconnectType : 1000,
  curReconnectData : -1,
  curUsePlatform : -1,       //0:webjs,1:android,2:ios;
  curOverLayer : -1,
  curSceneIndex : 0          //0:login;1:hall;2:game;
};


cfg.curVersion = "1.4.53";
cfg.oriPaomaText = "和谐游戏，拒绝赌博，如若发现，封号并提交公安机关处理。有事咨询客服，官方客服微信：lvyd001";
cfg.versionCheck = "1.4.01&LSKAHDUYAPSMHAKSSA";
cfg.resetGameData = function(){
  cfg.gameSceneLoadData = [];
  cfg.curReconnectData = -1;
  cfg.curSceneIndex = 1;
  cfg.roomPlayer = -1;
  cfg.roomId = -1;
  cfg.roomData = -1;
  cfg.meChair = 0;
  cfg.curPlayerCount = 0;
  cfg.curPlayerMax = 0;
  cfg.curPlayerData = {};
},


cfg.loginType = 0;   //0:游客登陆;1:微信登陆;2:h5微信登录


cfg.meWXHeadFrame = -1;
cfg.WXHeadFrameList = {};

cfg.playSoundByName = function(curName){
  if(cfg.audioList[curName])
    cc.audioEngine.play(cfg.audioList[curName],false,cfg.audioVolume);
};

cfg.getWXHearFrame = function(headUrl,index,cb) {
  console.log("WXHead index 1111111111111111111");
  // headUrl = headUrl + ".jpg";
  cc.loader.load({url:headUrl,type:'png'}, function (err, texture) {
    //console.log("WXHead URL === " + headUrl);
    console.log("WXHead index === " + index);
    var newFrame = new cc.SpriteFrame(texture);
    if(index == 0)
    {
      cfg.meWXHeadFrame = newFrame;
      cfg.WXHeadFrameList[index] = newFrame;
    }
    else{
      cfg.WXHeadFrameList[index] = newFrame;
    }

    if(cb)
      cb();
  });
};



module.exports = cfg;